package com.springboot.study.tests.single;

/**
 * @Author: guodong
 * @Date: 2021/5/27 11:22
 * @Version: 1.0
 * @Description:
 */
public class SingleTest1 {

    private static SingleTest1 singleTest1;

    private SingleTest1(){}

    public static synchronized SingleTest1 getInstance(){
        if(singleTest1 == null){
            singleTest1 = new SingleTest1();
            return singleTest1;
        }
        return singleTest1;
    }


    public static void main(String[]args){
        for(int i=0;i<200;i++){
            new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+":"+SingleTest1.getInstance().hashCode());
                }
            }).start();
        }
    }



}
